package com.ruoyi.web.controller.combat.useralignment;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.request.AntiAlignmentRequest;
import com.ruoyi.combat.domain.useralignment.CombatAlignmentWarn;
import com.ruoyi.combat.service.useralignment.ICombatAlignmentWarnService;
import com.ruoyi.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络用户身份对齐告警Controller
 * 
 * @author ruoyi
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/system/warn")
@Api("网络用户身份对齐告警")
public class CombatAlignmentWarnController extends BaseController
{
    @Autowired
    private ICombatAlignmentWarnService combatAlignmentWarnService;

    /**
     * 查询网络用户身份对齐告警列表
     */
    @PreAuthorize("@ss.hasPermi('system:warn:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatAlignmentWarn combatAlignmentWarn)
    {
        startPage();
        List<CombatAlignmentWarn> list = combatAlignmentWarnService.selectCombatAlignmentWarnList(combatAlignmentWarn);
        return getDataTable(list);
    }

    /**
     * 导出网络用户身份对齐告警列表
     */
    @PreAuthorize("@ss.hasPermi('system:warn:export')")
    @Log(title = "网络用户身份对齐告警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatAlignmentWarn combatAlignmentWarn)
    {
        List<CombatAlignmentWarn> list = combatAlignmentWarnService.selectCombatAlignmentWarnList(combatAlignmentWarn);
        ExcelUtil<CombatAlignmentWarn> util = new ExcelUtil<CombatAlignmentWarn>(CombatAlignmentWarn.class);
        util.exportExcel(response, list, "网络用户身份对齐告警数据");
    }

    /**
     * 获取网络用户身份对齐告警详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:warn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatAlignmentWarnService.selectCombatAlignmentWarnById(id));
    }
    @GetMapping(value = "/getInfo/{id}")
    @ApiOperation("获取网络用户身份对齐告警详细信息")
    public AjaxResult getInfoByid(@PathVariable("id") Long id)
    {
        return success(combatAlignmentWarnService.getInfoByid(id));
    }

    /**
     * 新增网络用户身份对齐告警
     */
    @Anonymous
    @PostMapping
    public AjaxResult add(@RequestBody CombatAlignmentWarn combatAlignmentWarn) {
        return toAjax(combatAlignmentWarnService.insertCombatAlignmentWarn(combatAlignmentWarn));
    }
    @Anonymous
    @PostMapping("/add")
    public AjaxResult addData(@RequestBody List<CombatAlignmentWarn> list) {
        for (CombatAlignmentWarn combatAlignmentWarn : list){
            combatAlignmentWarnService.insertCombatAlignmentWarn(combatAlignmentWarn);
        }
        try {
            Thread.sleep(3000L);
        } catch (InterruptedException e) {

        }
        return success();
    }

    /**
     * 修改网络用户身份对齐告警
     */
    @PreAuthorize("@ss.hasPermi('system:warn:edit')")
    @Log(title = "网络用户身份对齐告警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatAlignmentWarn combatAlignmentWarn)
    {
        return toAjax(combatAlignmentWarnService.updateCombatAlignmentWarn(combatAlignmentWarn));
    }

    /**
     * 删除网络用户身份对齐告警
     */
    @PreAuthorize("@ss.hasPermi('system:warn:remove')")
    @Log(title = "网络用户身份对齐告警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatAlignmentWarnService.deleteCombatAlignmentWarnByIds(ids));
    }




  /*  *//**
     * 抗对齐
     *//*
    @Log(title = "网络用户身份对齐告警", businessType = BusinessType.UPDATE)
    @PostMapping("antiAlignment")
    public AjaxResult antiAlignment(@RequestBody AntiAlignmentRequest antiAlignmentRequest) {
        String result = combatAlignmentWarnService.antiAlignment(antiAlignmentRequest);
        return success();
    }*/

    /**
     * 统计
     */
    @GetMapping("/statistics")
    public AjaxResult statistics() {
        return success(combatAlignmentWarnService.statistics());
    }

}
